

// PCL
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/common/transforms.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/filters/approximate_voxel_grid.h>
#include <pcl/registration/gicp.h>

#include <geometry_utils/Transform3.h>
#include <sstream>
#include <fstream>
#include <iostream>
#include <string>
#include "time_counter.hpp"
#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>

using namespace std;

int getBinSize(std::string path)
{
    int size = 0;
    std::ifstream infile(path, std::ifstream::binary);

    infile.seekg(0, infile.end);
    int size = infile.tellg();
    infile.seekg(0, infile.beg);

    infile.close();
    printf("\npath=%s,size=%d \n", path, size);
    return size;
}

void readBin(std::string path, char *buf, int size)
{
    std::ifstream infile(path, std::ifstream::binary);

    infile.read(static_cast<char *>(buf), size);
    infile.close();
}

int main(int argc, char **argv)
{
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);

    // read binFile
    std::string filePath = "./demo.bin";
    int size = getBinSize(filePath);
    char *buf = new char[size];
    readBin(filePath, buf, size);
    float *fbuf = reinterpret_cast<float *>(buf);

    delete buf;

    return 0;
}
